<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link type="text/css" rel="stylesheet" href="../css/RedeemCode.css">
    <title>兑换码</title>
</head>
<body>
<div class="body">
    <!--兑换码查询-->
    <div id='find-package' class="package">
        <header>
            <p>兑换码查询</p>
        </header>
        <div class="content">
            <input oninput="OnInput (event)" id="code" type="text" placeholder="请输入兑换码">
            <p id="msg"></p>
            <button id="button" onclick="query()" disabled="disabled">查&nbsp;询</button>
        </div>
    </div>
    <!--兑换套餐-->
    <div id='package-details' class="package">
        <header>
            <p>兑换套餐</p>
        </header>
        <div id="content">
            <div>
                <h2>套餐详情</h2>
                <div>
                    <input id = '01' type="text" value=""readonly>
                </div>
                <div>pormt</div>
                <ul>
                    <li>有效期1年</li>
                    <li>每月100G流量</li>
                    <li>支持同时在线：3台终端</li>
                    <li>加速方式：fast</li>
                    <li>全球节点</li>
                </ul>
                <div>
                    <p>该套餐与当前套餐一至将延长时间，不一致将覆盖，请慎重选择</p>
                </div>
            </div>
            <div>
                <button>确&nbsp;定</button>
            </div>
        </div>
    </div>
</div>
<script>
    var a = document.getElementById('01');
    a.value = '123456789';
    var code = document.getElementById('code');
    var msg = document.getElementById('msg');
    var details = document.getElementById('package-details');
    var find = document.getElementById('find-package');
    var button = document.getElementById('button');
    console.log(button);
    //监听获取input值
    function OnInput (event) {
        var Number = event.target.value;//获取输入内容
        console.log(Number);
        //正则匹配16为数字加字母
        var reg1 =  /(?!^\d+$)(?!^[a-zA-Z]+$)[0-9a-zA-Z]{16}$/;
        //正则匹配手机号码
        if((reg1.test(Number))){
            //若匹配成功解除领取按钮的禁止点击事件，和按钮颜色
            button.disabled = false;
            button.style.backgroundColor = '#ff740a';
            console.log('123')
        }else {
            button.disabled =true;
            button.style.backgroundColor = '#7b8080';
        }
    }
    //点击兑换套餐
    function query(){
        if(code.value != 'undefind'){
            details.style.display = 'block';
            find.style.display = 'none';
        }
    }
</script>
</body>
</html>